package com.mszlu.news.admin.controller;

import com.mszlu.news.admin.model.params.UserParam;
import com.mszlu.news.admin.service.SysUserService;
import com.mszlu.news.admin.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户接口")
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private SysUserService sysUserService;

    @ApiOperation(value = "根据条件查询")
    @PostMapping("select")
    public Result selectUser(@RequestBody UserParam userParam){
        return sysUserService.selectUser(userParam);
    }

    @ApiOperation(value = "新增用户")
    @PostMapping("insert")
        public Result insertUser(@RequestBody UserParam userParam){
        return sysUserService.insertUser(userParam);
    }

    @ApiOperation(value = "更新用户")
    @PostMapping("update")
    public Result updateUser(@RequestBody UserParam userParam){
        return sysUserService.updateUser(userParam);
    }

    @ApiOperation(value = "统计已注册男女人数")
    @GetMapping("sexCounts")
    public Result UserSexCounts(){
        return sysUserService.UserSexCounts();
    }

    @ApiOperation(value = "通过id删除用户")
    @PostMapping("delete/{id}")
    public Result deleteUserById(@PathVariable("id") Long userId){
        return sysUserService.deleteUserById(userId);
    }
}
